package com.diamond.web.exceptions;

public class AppException extends Exception{

	/**
	 * 
	 */
	private static final long serialVersionUID = -9137162600063494193L;
	public static final int USER_EXIST = 1;
	public static final int ROLE_SIGN_EXISTS = 2;
	
	private int code;
	public int getCode() {
		return code;
	}


	public void setCode(int code) {
		this.code = code;
	}


	public AppException() {
	}
	
	public AppException(int code) {
		this.code=code;
	}
	
	
	@Override
	public String getMessage() {
		switch (code) {
		case USER_EXIST:
			return "用户名已存在！";
		case ROLE_SIGN_EXISTS:
			return "角色标示已存在！";
		default:
			break;
		}
		return super.getMessage();
	}
	
}
